/**
 * @file rootNavigation.js
 * @description 在普通js tsx文件中获取以及使用路由对象，进行跳转
 * @reference https://reactnavigation.org/docs/navigating-without-navigation-prop/
 */
import { createNavigationContainerRef } from "@react-navigation/native";

export const navigationRef = createNavigationContainerRef();

export function navigate(name,params){
    // 通过isReady判断导航组件是否已经初始化
    // 初始化后再进行跳转，否则会报错
    // https://reactnavigation.org/docs/navigating-without-navigation-prop/#handling-initialization
    if(navigationRef.isReady()){
        navigationRef.navigate(name,params);
    }
}